<?php

declare(strict_types=1);

namespace So\Command;

use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Symfony\Component\Console\Input\InputOption;

/**
 * @Command
 */
class CurdCommand extends HyperfCommand
{
    /**
     * 执行的命令行
     *
     * @var string
     */
    protected $name = 'so:curd';

    public function handle()
    {
        $table = $this->input->getOption('table'); // 表名
        $field = $this->input->getOption('field'); // 显示字段
        $force = $this->input->getOption('force'); // 强制模式
        $catalogue = $this->input->getOption('catalogue'); // 目录
        $with = $this->input->getOption('with'); // 关联模型
        $withforeignkey = $this->input->getOption('withforeignkey'); // 关联模型外键
        $withprimarykey = $this->input->getOption('withprimarykey'); // 关联模型主键
        $withmode = $this->input->getOption('withmode'); // 关联模式
        $checkboxsuffix = $this->input->getOption('checkboxsuffix'); // 复选框字段
        $radiosuffix = $this->input->getOption('radiosuffix'); // 单选框字段
        $imagesuffix = $this->input->getOption('imagesuffix'); // 图片字段
        $datesuffix = $this->input->getOption('datesuffix'); // Date字段
        $timesuffix = $this->input->getOption('timesuffix'); // Time字段
        $datetimesuffix = $this->input->getOption('datetimesuffix'); // Datetime字段
        $colorsuffix = $this->input->getOption('colorsuffix'); // 颜色选择字段
        $switchsuffix = $this->input->getOption('switchsuffix'); // 开关字段
        $slidersuffix = $this->input->getOption('slidersuffix'); // 滑块字段
        $selectsuffix = $this->input->getOption('selectsuffix'); // 远程下拉框字段
        $ignorefield = $this->input->getOption('ignorefield'); // 排除字段
        $editorsuffix = $this->input->getOption('editorsuffix'); // 富文本字段
        $sortfield = $this->input->getOption('sortfield'); // 排序字段
        $timestamps = $this->input->getOption('timestamps'); // 时间戳字段
        $search = $this->input->getOption('search'); // 模块搜索字段
        $operate = $this->input->getOption('operate'); // 可操作字段
        if (!$table){
            return $this->error('请填写表名 -t or --table');
        }
        
        $this->line($table, 'info');
    }

    public function configure()
    {
        parent::configure();
        $this->addOption('table', 't', InputOption::VALUE_REQUIRED, '表名', null);
        $this->addOption('field', 'f', InputOption::VALUE_REQUIRED, '显示字段', null);
        $this->addOption('force', 'c', InputOption::VALUE_REQUIRED, '强制模式', null);
        $this->addOption('catalogue', 'l', InputOption::VALUE_REQUIRED, '目录', null);
        $this->addOption('with', 'w', InputOption::VALUE_REQUIRED, '关联模型', null);
        $this->addOption('withforeignkey', 'k', InputOption::VALUE_REQUIRED, '关联模型外键', null);
        $this->addOption('withprimarykey', 'p', InputOption::VALUE_REQUIRED, '关联模型主键', null);
        $this->addOption('withmode', 'm', InputOption::VALUE_REQUIRED, '关联模式', null);
        $this->addOption('checkboxsuffix', 'checkbox', InputOption::VALUE_REQUIRED, '复选框字段', null);
        $this->addOption('radiosuffix', 'radio', InputOption::VALUE_REQUIRED, '单选框字段', null);
        $this->addOption('imagesuffix', 'image', InputOption::VALUE_REQUIRED, '图片字段', null);
        $this->addOption('datesuffix', 'date', InputOption::VALUE_REQUIRED, 'Date字段', null);
        $this->addOption('timesuffix', 'time', InputOption::VALUE_REQUIRED, 'Time字段', null);
        $this->addOption('datetimesuffix', 'datetime', InputOption::VALUE_REQUIRED, 'Datetime字段', null);
        $this->addOption('colorsuffix', 'color', InputOption::VALUE_REQUIRED, '颜色选择字段', null);
        $this->addOption('switchsuffix', 'switch', InputOption::VALUE_REQUIRED, '开关字段', null);
        $this->addOption('slidersuffix', 'slider', InputOption::VALUE_REQUIRED, '滑块字段', null);
        $this->addOption('selectsuffix', 'select', InputOption::VALUE_REQUIRED, '远程下拉框字段', null);
        $this->addOption('ignorefield', 'i', InputOption::VALUE_REQUIRED, '排除字段', null);
        $this->addOption('editorsuffix', 'editor', InputOption::VALUE_REQUIRED, '富文本字段', null);
        $this->addOption('sortfield', 's', InputOption::VALUE_REQUIRED, '排序字段', null);
        $this->addOption('timestamps', 'z', InputOption::VALUE_REQUIRED, '时间戳字段', null);
        $this->addOption('search', 'search', InputOption::VALUE_REQUIRED, '模块搜索字段', null);
        $this->addOption('operate', 'o', InputOption::VALUE_REQUIRED, '可操作字段', null);
    }
}